package com.aat.dxfy.mouse;

import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Hello world!
 *
 */
public class App {

	public static void action() {
		Calendar c = Calendar.getInstance();
		int d = c.get(Calendar.DATE);
		c.set(Calendar.DATE, d + 1);
		c.set(Calendar.HOUR_OF_DAY, 8);
		int mi = (int) (40 + Math.random() * 10);
		c.set(Calendar.MINUTE, mi);

		Date tomorrow = new Date(c.getTimeInMillis());
		Timer t = new Timer();
		TimerTask task = new TimerTask() {
			@Override
			public void run() {
				System.out.println("now: " + new Date());
				try {
					Runtime.getRuntime().exec("D:\\devSoftin\\putty.exe");
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		};
		long delay = 24 * 60 * 60 * 1000;
		t.schedule(task, tomorrow, delay);
		t.schedule(task, new Date(), 5000);
	}

	public static List<XY> getXY() {
		List<XY> list = new ArrayList<XY>();
		try {
			String filepath = "E:\\workspace\\app01\\src\\main\\java\\xy.txt";
			File file = new File(filepath);
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line = null;
			while ((line = br.readLine()) != null) {
				if (line != null) {
					String[] ss = line.split(",");
					if (ss.length > 0) {
						int x = Integer.parseInt(ss[0].trim());
						int y = Integer.parseInt(ss[1].trim());
						System.out.println(x + "  " + y);
						XY xy = new XY(x, y);
						list.add(xy);
					}
				}
			}
			br.close();
		} catch (Exception e) {
		}
		return list;
	}

	public static void main(String[] args) {
		try {
			Thread.sleep(10000);
			Robot robot = new Robot();
			robot.delay(1000);
			RobotExp.pressKey(robot, KeyEvent.VK_1);
			RobotExp.pressKey(robot, KeyEvent.VK_2);
			RobotExp.pressKey(robot, KeyEvent.VK_3);
			RobotExp.pressKey(robot, KeyEvent.VK_6);
			robot.delay(1000);
			RobotExp.pressKey(robot, KeyEvent.VK_ENTER);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

class XY {
	private int x;
	private int y;

	public XY(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

}
